import http from '../utils/http';
import {
  formatFormObject
} from '../utils';

export default {
  isLogin() {
    return http.post('ticket/isLogin');
  },
  signin(mobile, countryCode, code) {
    return http.post('ticket/register', {
      mobile,
      countryCode,
      code
    });
  },
  sendCode(mobile, countryCode) {
    return http.post('ticket/sendCode', {
      mobile,
      countryCode
    });
  },
  getUserList() {
    return http.post('ticketPurchaseMob/queryTicketPsnLinkerByUserId').then(res => {
      if (!res.result || !Array.isArray(res.result)) return [];
      return res.result.map(item => formatFormObject(item));
    });
  },
  getOrderList() {
    return http.get('ticket/order').then(res => res.result);
  }
};
